package top.tangs.vitamin.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


import top.tangs.vitamin.entity.Informationparticulars;
import top.tangs.vitamin.entity.Productdetails;
import top.tangs.vitamin.util.DBManager;

public class InformationparticularsDaoImpl {
//	查询数据库中的数据
	public List<Informationparticulars> getInformationparticularsList() {
		List<Informationparticulars> list = new ArrayList<Informationparticulars>();
		// 1获取连接
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		try {
			// 2创建statement对象(执行SQL语句)
			st = conn.createStatement();
			// 3。SQL语句
			String sql = "SELECT * FROM informationparticulars,informationclassification WHERE informationClassificationID = InformationParticularsClassification";

			// 4.执行SQL语句
//		st.executeQuery(sql);//

			rs = st.executeQuery(sql);//

//		5.便利结果集;
			while (rs.next()) {
				int particularsId = rs.getInt("InformationParticularsId");
				String particularsTitle = rs.getString("InformationParticularsTitle");
				String particularsContent = rs.getString("InformationParticularsContent");
				Date particularsTime = rs.getDate("InformationParticularsTime");

				int classificationID = rs.getInt("informationClassificationID");
				String classificationName = rs.getString("informationClassificationName");

				Informationparticulars informationparticularsList = new Informationparticulars(particularsId,particularsTitle,particularsContent,particularsTime,classificationID,classificationName);
				list.add(informationparticularsList);
			}
			return list;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		} finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
